<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<img src="./../img/5.jpg" alt="想要天上的月亮">



<script>
    const imgElement = document.querySelector('img');

    const prefix = Math.floor(Math.random() * 8)
    document.write('./../img/' + prefix + '.jpg')
    imgElement.src = './../img/' + prefix + '.jpg'

</script>

</body>
</html>